package com.atguigu.gmall.payment.weixin.config;

import com.atguigu.gmall.payment.weixin.config.properties.WxPayConfigProperties;
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WxPayConfiguration {



    /**
     * 获取微信支付配置对象
     * @return
     */
    @Bean
    public RSAAutoCertificateConfig getConfig(WxPayConfigProperties wxPayConfigProperties){

        return new RSAAutoCertificateConfig.Builder()
                .merchantId(wxPayConfigProperties.getMchId())
                .privateKeyFromPath(wxPayConfigProperties.getPrivateKeyPath())
                .merchantSerialNumber(wxPayConfigProperties.getMchSerialNo())
                .apiV3Key(wxPayConfigProperties.getApiV3Key())
                .build();
    }
}
